pp108 : Triggering a Case Model from an XForm

Triggering a Case Model from an XForm

This topics describes the procedure to trigger a case model from an XForm.

[CreateCase] Web service operation is used to trigger a case model. This Web service operation is also used to pass case data and case variable details.
You can use an User interface document to capture input details and map them to case data and case variables.

Steps to trigger a case model

As an example, consider a business scenario where you fill details of a claim and trigger a case model. After you fill in the necessary set of details in the form, and click the Submit button, the claim case model should be triggered.

  1. Create an XML Schema document with below xml data. It will create a Schema fragment with name ClaimDetails
    <ns:ClaimDetails xmlns:ns="http://myinsurance/claim/1.0">
        <ns:ClaimAmount/>
        <ns:CustomerID/>
        <ns:PolicyID/>
        <ns:PolicyType/>
    </ns:ClaimDetails>
    
  2. Create a case model and associate the above Schema fragment document as case data
  3. Create a User Interface document and drag the above Schema fragment document onto the User interface. This will automatically create the view with group box and input controls based on the schema
  4. Double click on User interface model editor area and go to the properties view. Add Init Done event and create a data model with below code.
    function Form_InitDone(eventObject)
    {
        claimDetailsGroupBox.create();
    }
    
  5. Create a non-transactional Model TriggerCaseModel that uses the [CreateCase] Web service operation to fire a request to initiate the case model from the User Interface.
    In this case, add the following XML to the XML Editor.
    <xml id="triggerCaseReqXML">
        <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
            <SOAP:Body>
                <CreateCase xmlns="http://schemas.cordys.com/casemanagement/execution/1.0">
                    <model space="organization">Case/ClaimCase</model>
                    <casedata>
                        <data name="ClaimDetails" xmlns="http://myinsurance/claim/1.0"/>
                    </casedata>
                </CreateCase>
            </SOAP:Body>
        </SOAP:Envelope>
    </xml>
    
  6. Write the code to send requests to the business process engine to trigger the case model. Add a button and add the following code for the onclick event of the button
    function submitBtn_Click(eventObject)
    {
        var caseSOAPRequest = cordys.cloneXMLDocument(triggerCaseReqXML.XMLDocument);
        var modelDataNode = cordys.cloneXMLDocument(ClaimDetailsModel.getData());
        var claimDetailsNode = cordys.selectXMLNode(modelDataNode,".//*[local-name()='ClaimDetails']");
        
        var casedataNode = cordys.selectXMLNode(caseSOAPRequest,".//*[local-name()='data']");
        cordys.appendXMLNode(claimDetailsNode,casedataNode);
        TriggerCaseModel.setMethodRequest(caseSOAPRequest);
        TriggerCaseModel.reset()    
    }
    

The above script will be called on click of a button. It sends the above SOAP request with specified input parameters.

The User interface from which you can trigger the case model is created.